<?php
namespace app\admin\model;
use think\Model;
use think\model\concern\SoftDelete;

class AdminRole extends Model
{
    use SoftDelete;
    protected $deleteTime = 'delete_time';
    protected $defaultSoftDelete = 0;

    /**
     * 权限转数组 保存
     * @param $value
     * @return array|string
     */
    public function setRolesAttr($value)
    {
        if(!$value){
            $list = array();
        }else{
            $list = implode(',',array_filter($value));
        }
        return $list;
    }

    /**
     * 权限转数组 读取
     * @param $value
     * @return array|false|string[]
     */
    public function getRolesAttr($value)
    {
        if(!$value){
            $list = array();
        }else{
            $list = explode(',', $value);
        }
        return $list;
    }

}